#include <stdio.h>
#include<stdlib.h>
typedef char BTDataType;
typedef struct BinaryTreeNode {
    BTDataType val;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
}BTNode;

BTNode* BTCreate(char* a, int* pi) {
    if (a[*pi] == '#') {
        (*pi)++;
        return NULL;
    }
    BTNode* root = (BTNode*)malloc(sizeof(BTNode));
    if (root == NULL) {
        perror("malloc fail");
        exit(-1);
    }
    root->val = a[(*pi)++];
    root->left = BTCreate(a, pi);
    root->right = BTCreate(a, pi);
    return root;
}
void InOrder(BTNode* root) {
    if (root == NULL) {
        return;
    }
    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);
}
int main() {
    char a[100];
    while (scanf("%s", a) != EOF) {
        int i = 0;
        BTNode* root = BTCreate(a, &i);
        InOrder(root);
    }
    return 0;
}